<template>
  <div class="minitabbar">
     <div
     v-for="(item,index) in tabberList"
     class="minitabbar-item"
     @click="tabClick(index)"
     :class="{active: index === currentIndex}">
        <span>{{item}}</span>
     </div>
  </div>
</template>

<script>
export default {
  name: 'minitabbar',
  data() {
    return {
      currentIndex: 0
    }
  },
  props: {
    tabberList: {
      type: Array,
      default() {
        return []
      }
    }
  },
  methods: {
    tabClick(index) {
      this.currentIndex = index
      this.$bus.$emit('tabbarClick', index)
    }
  },
  created() {
    this.$bus.$on('changeindex', (index) => {
      this.currentIndex = index
    })
  },
}
</script>

<style lang='stylus' scoped>
.minitabbar
   display flex
   text-align center
   font-size: 14px;
   height: 40px;
   line-height: 40px;
   background-color: #fff;
   .minitabbar-item
      flex 1
      span
        padding: 5px 10px
   .active
      color #ff8198
      span
        border-bottom 1px solid #ff8198
</style>